package org.example.dao.impl;

import lombok.Cleanup;
import lombok.Setter;
import org.example.dao.IEmployeeDao;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-11-11 9:30
 */
@Setter
public class EmployeeDaoImpl implements IEmployeeDao {
    private DataSource dataSource;
    @Override
    public void register(String username, String password) throws SQLException {
//        System.out.println("注册成功");
//        Connection connection = dataSource.getConnection();
        @Cleanup
        Connection connection = dataSource.getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement("insert into employee (username,password) values (?,?)");
        preparedStatement.setString(1,username);
        preparedStatement.setString(2,password);
        preparedStatement.executeUpdate();
    }
}
